feat(mysql): improve AST formatting and add DELETE JOIN support#4206
Merged
kyleconroy merged 1 commit intomainfrom Nov 30, 2025
Merged
feat(mysql): improve AST formatting and add DELETE JOIN support#4206kyleconroy merged 1 commit intomainfrom
kyleconroy merged 1 commit intomainfrom
Conversation
This PR continues the MySQL AST formatting work with several improvements: **New AST Nodes:** - `VariableExpr` - MySQL user variables (@var), distinct from sqlc @param - `IntervalExpr` - MySQL INTERVAL expressions - `OnDuplicateKeyUpdate` - MySQL ON DUPLICATE KEY UPDATE clause - `ParenExpr` - Explicit parentheses for expression grouping **DELETE with JOIN Support:** - Extended DeleteStmt with Targets and FromClause fields - Multi-table DELETE now properly formats: DELETE t1.*, t2.* FROM t1 JOIN t2... - Updated compiler/output_columns.go to handle new structure **Bug Fixes:** - MySQL @variable now preserved as-is (not treated as sqlc named parameter) - Column type lengths only output for types where meaningful (varchar, char) - Fixed sqlc.arg() handling in ON DUPLICATE KEY UPDATE clause **Documentation:** - Added CLAUDE.md files documenting AST, astutils, named, rewrite packages - Added CLAUDE.md for dolphin engine with conversion patterns 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR continues the MySQL AST formatting work with several improvements:
New AST Nodes
VariableExpr- MySQL user variables (@var), distinct from sqlc's@paramsyntaxIntervalExpr- MySQL INTERVAL expressionsOnDuplicateKeyUpdate- MySQL ON DUPLICATE KEY UPDATE clauseParenExpr- Explicit parentheses for expression groupingDELETE with JOIN Support
DeleteStmtwithTargetsandFromClausefieldsDELETE t1.*, t2.* FROM t1 JOIN t2 ON ...compiler/output_columns.goto handle new structure for table resolutionBug Fixes
@variablenow preserved as-is in output (not treated as sqlc named parameter)sqlc.arg()handling in ON DUPLICATE KEY UPDATE clause by adding field to rewrite traversalDocumentation
Added CLAUDE.md files documenting key packages:
internal/sql/ast/- AST nodes and formattinginternal/sql/astutils/- Walk and Apply functionsinternal/sql/named/- Named parameter detectioninternal/sql/rewrite/- Parameter rewritinginternal/engine/dolphin/- MySQL/TiDB conversion patternsTest plan
TestFormattests pass (including previously failing delete_join tests)TestReplaytests pass🤖 Generated with Claude Code